/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-03-05
 * Time: 17:17
 */
public interface IUSB {
    void openDives();
    void closeDives();

    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.powerOn();
        computer.useDevice(new KeyBoard());
        computer.useDevice(new Mouse());
        computer.powerOff();
    }
}
class Computer {
    public void powerOn() {
        System.out.println("打开笔记本电脑");
    }

    public void powerOff() {
        System.out.println("关闭笔记本电脑");
    }
    public void useDevice(IUSB usb) {
        usb.openDives();
        if(usb instanceof Mouse) {
            Mouse mouse = (Mouse)usb;
            mouse.Click();
        }
        if(usb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.input();
        }
        usb.closeDives();
    }
}
class Mouse implements IUSB {

    @Override
    public void openDives() {
        System.out.println("打开鼠标");
    }

    @Override
    public void closeDives() {
        System.out.println("关闭鼠标");
    }

    public void Click() {
        System.out.println("点击鼠标");
    }
}


class KeyBoard implements IUSB{

    @Override
    public void openDives() {
        System.out.println("打开键盘");
    }

    @Override
    public void closeDives() {
        System.out.println("关闭键盘");
    }

    public void input() {
        System.out.println("使用键盘");
    }
}
